package cn.project.lemontree.service.impl;

import cn.project.lemontree.bean.Diary;
import cn.project.lemontree.service.DiaryService;
import cn.project.lemontree.dao.DiaryDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("diaryService")
public class DiaryServiceimpl extends ServiceImpl<DiaryDao, Diary> implements DiaryService {
    @Resource
    private DiaryDao diaryDao;

    @Override
    public List<Diary> listpage(int page,int size,String theme){
        return diaryDao.listpage((page - 1) * size,size,theme);
    }

    @Override
    public int count(String theme){
        return diaryDao.count(theme);
    }

    @Override
    public boolean saveDiary(Diary diary) {
        return diaryDao.save(diary)>0;
    }

    @Override
    public boolean update(Diary diary) {
        return diaryDao.update(diary)>0;
    }

    @Override
    public List<Diary> newListpage(int page, int size, String theme, Integer parentId) {
        return diaryDao.newListpage((page-1)*size,size,theme,parentId);
    }

    @Override
    public int newCount(String theme, Integer parentId) {
        return diaryDao.newCount(theme,parentId);
    }
}
